//  this library.
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:hktk_app/ienum/my/asset_status_enum.dart';
import 'package:hktk_app/util/font_util.dart';
import 'package:hktk_app/util/view_util.dart';

/// 卡片外围标签
class CardWidget extends StatelessWidget {
  /// 状态
  final AssetStatusEnum efficientStatus;

  /// 卡片内容
  final Widget child;

  const CardWidget({
    super.key,
    required this.efficientStatus,
    required this.child,
  });

  @override
  Widget build(BuildContext context) {
    return efficientStatus == AssetStatusEnum.effective
        ? _unexpiredItem()
        : _expireItem();
  }

  /// 未过期显示组件
  Widget _unexpiredItem() {
    return Padding(
      padding: EdgeInsets.symmetric(horizontal: 6),
      child: child,
    );
  }

  /// 过期显示组件
  Widget _expireItem() {
    return Container(
      padding: EdgeInsets.fromLTRB(6, 0, 6, 6),
      decoration: BoxDecoration(
        color:
        efficientStatus == AssetStatusEnum.overdue ? colorRed5 : colorGrey5,
        borderRadius: BorderRadius.all(Radius.circular(24)),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          _expireTitle(),
          child,
        ],
      ),
    );
  }

  /// 未过期标题
  _expireTitle() {
    return Container(
      height: 48,
      padding: EdgeInsets.symmetric(horizontal: 24),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          SvgPicture.asset(
            "images/my/bank_card_expire.svg",
            width: 22,
            height: 22,
          ),
          hiSpace(width: 9),
          Padding(
            padding: EdgeInsets.only(bottom: 3),
            child: Text(
              efficientStatus.desc,
              style: FontUtil.fontWhile1(22),
            ),
          ),
        ],
      ),
    );
  }
}
